home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindspring.com!usenet
- From: rudd@mindspring.com (Justin Rudd)
- Newsgroups: comp.lang.c++
- Subject: Re: help on syntax
- Date: 4 Jan 1996 00:44:34 GMT
- Organization: N/A
- Message-ID: <4cf7ti$14sk@firehose.mindspring.com>
- References: <96002.222728APCCU@CUNYVM.CUNY.EDU>
- NNTP-Posting-Host: rudd.mindspring.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- > if (c = (a-b))
- > cout << "a: ";
- > cout << a;
- > cout << " minus b: ";
- > cout << b;
- > cout << " quals c: ";
- > cout << c << endl;
- > else
- > cout << "a-b does not equal c: " << endl;
- >
- >}
-
- Well first off if you are trying to check to see if C equals (a-b) you need to
- use the double equals marks: ==. What you are doing is assigning a-b to c.
- Also since you have more then one statement after the if you need braces like
- this:
- if( c == (a-b))
- {//opening brace
- cout << "a: ";
- //the rest of your stuff here
- }//closing brace
-
- > if (c = (a-b))
- > cout << "a: " << a << " minus b: " << b << " equals c: " << c;
- > else
- > cout << "a-b does not equal c: ";
- >}
- >
- >
-
- The if statement should also be using the double equals marks: == to check for
- equality. Also the reason this if statement works is because you only have
- one statement following the if.
-
- Justin Rudd
- rudd@mindspring.com
- http://www.mindspring.com/~jleonard/
- (334)-855-4680
-
-
-
-